<h2>Opportunity Details</h2>  
<?php
    $this->headTitle('Opportunity Details');
    $this->headScript()->appendFile('/js/BizSense/Crud.js');   
    echo $this->message;
    echo $this->form;
    $acl = $this->acl;    
?>
<?php
	$opportunity = $this->opportunity;
?>
<?php if  ($acl->isAllowed($this->currentUser, 'access opportunity pages')): ?>
<a href="<?php echo $this->url(
    array(
        'module' => 'default', 
        'controller' => 'opportunity'
    ), NULL, true
);?>">Opportunity</a> | 
<?php endif; ?>

<?php if  ($acl->isAllowed($this->currentUser, 'access opportunity pages')): ?>
<a href="<?php echo $this->url(
    array(
        'module' => 'default', 
        'controller' => 'opportunity', 
        'action' => 'edit', 
        'opportunity_id' => $this->escape($opportunity->opportunity_id)
    ), NULL, true
); ?>">Edit</a> |
<?php endif; ?>

<?php if  ($acl->isAllowed($this->currentUser, 'access opportunity pages')): 
    $deleteUrl = $this->url(
                 array(
                  'module' => 'default', 
                  'controller' => 'opportunity', 
                  'action' => 'delete', 
                 'opportunity_id' => $this->escape($opportunity->opportunity_id)
                    )
                );
                echo $this->deleteButton($deleteUrl); 
 endif; ?>
|


<?php if  ($acl->isAllowed($this->currentUser, 'access opportunity pages')): ?>
<a href="<?php echo $this->url(
    array(
        'module' => 'default', 
        'controller' => 'opportunity', 
        'action' => 'notes', 
        'opportunity_id' => $this->escape($opportunity->opportunity_id)
    ), NULL, true
); ?>">Notes</a>
<?php endif; ?>

<table class="data_table">
	<tr><td>Opportunity name</td>
        <td class="mediumshort">
            <?php echo  $this->escape($opportunity->name); ?>
        </td>
    </tr>
	<tr>
        <td>Amount</td>
        <td>
            <?php 
                $amount = $this->escape($opportunity->amount);
                echo $this->currencySymbol()." ".$amount;
            ?>
        </td>
    </tr>
	<tr>
        <td>Expected Close Date</td><td>
            <?php 
                echo  $this->escape($this->timestampToHuman(
                    $opportunity->expected_close_date)); 
            ?>
        </td>
    </tr>
	<tr>
        <td>Account</td>
        <td>
            <a href="<?php
               echo $this->url(
                    array(
                        'module' => 'default',
                        'controller' => 'account',
                        'action' => 'viewdetails',
                        'account_id' => $this->escape($opportunity->account_id),
                    ), NULL, TRUE
                ); 
                ?>">
            <?php 
                echo  $this->escape($opportunity->account_name); 
            ?>
            </a>
        </td></tr>
	<tr>
        <td>Contact</td><td>
        <?php 
            if ($opportunity->customer_type == Core_Model_Opportunity::CUSTOMER_TYPE_CONTACT) {
                $contactModel = new Core_Model_Contact($opportunity->contact_id);
                ?>
                <a href="<?php echo $this->url(
                    array(
                        'module' => 'default',
                        'controller' => 'contact',
                        'action' => 'viewdetails',
                        'contact_id' => $opportunity->contact_id,
                    ), 'default', true
                ); ?>">
                <?php echo $this->escape($contactModel->getFullName()); ?>
                </a>
                <?php
            }
        ?></td></tr>
    <tr>
        <td>Lead Source</td>
        <td>
            <?php echo $this->escape($opportunity->source); ?>
        </td>
    </tr>    
    <tr>
        <td>Sales Stage</td>
        <td>
            <?php echo  $this->escape($opportunity->stage); ?>
        </td>
    </tr>    
    <tr>
        <td>Campaign id </td>
        <td><?php if ($opportunity->campaign_id) {
                $campaignName = $this->campaignNameById($opportunity->campaign_id);
                echo $this->escape($campaignName);
            } ?> 
        </td>
    </tr>

    <tr>
        <td>Assigned To</td>
        <td>
            <?php  echo $this->escape($opportunity->email); ?>
        </td></tr>    
    <tr>
        <td>Branch</td>
        <td>
            <?php echo  $this->escape($opportunity->branch_name); ?>
        </td></tr>    
	<tr>
        <td>Description</td>
        <td>
            <?php echo  $this->escape($opportunity->description); ?>
        </td>
    </tr>
</table>
